package com.rs.net.decoders.handlers;

import java.text.NumberFormat;
import java.util.HashMap;
import java.util.TimerTask;
import com.rs.Settings;
import com.rs.cache.loaders.ItemDefinitions;
import com.rs.content.skills.SummoningScroll;
import com.rs.cores.CoresManager;
import com.rs.game.Animation;
import com.rs.game.Graphics;
import com.rs.game.World;
import com.rs.game.WorldTile;
import com.rs.game.grandexchange.GrandExchange;
import com.rs.game.item.Item;
import com.rs.game.minigames.Crucible;
import com.rs.game.minigames.duel.DuelControler;
import com.rs.game.npc.familiar.Familiar;
import com.rs.game.npc.familiar.Familiar.SpecialAttack;
import com.rs.game.player.CombatDefinitions;
import com.rs.game.player.EmotesManager;
import com.rs.game.player.Equipment;
import com.rs.game.player.Inventory;
import com.rs.game.player.Player;
import com.rs.game.player.QuestManager.Quests;
import com.rs.game.player.Skills;
import com.rs.game.player.actions.FightPitsViewingOrb;
import com.rs.game.player.actions.HomeTeleport;
import com.rs.game.player.actions.JewelryCrafting;
import com.rs.game.player.actions.JewelryCrafting.JewerlyData;
import com.rs.game.player.actions.Rest;
import com.rs.game.player.actions.Smithing.ForgingInterface;
import com.rs.game.player.actions.Summoning;
import com.rs.game.player.content.AdventurersLog;
import com.rs.game.player.content.AncientEffigies;
import com.rs.game.player.content.Combat;
import com.rs.game.player.content.ConstructFurniture;
import com.rs.game.player.content.CrystalSystem;
import com.rs.game.player.content.ItemConstants;
import com.rs.game.player.content.Magic;
import com.rs.game.player.content.MakePlank;
import com.rs.game.player.content.Notes.Note;
import com.rs.game.player.content.PlayerLook;
import com.rs.game.player.content.Runecrafting;
import com.rs.game.player.content.SandwichLadyHandler;
import com.rs.game.player.content.Shop;
import com.rs.game.player.content.SkillCapeCustomizer;
import com.rs.game.player.content.SkillsDialogue;
import com.rs.game.player.content.SquealOfFortune;
import com.rs.game.player.content.dungeoneering.DungeonRewards;
import com.rs.game.player.dialogues.LevelUp;
import com.rs.game.player.dialogues.Transportation;
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;
import com.rs.io.InputStream;
import com.rs.net.decoders.WorldPacketsDecoder;
import com.rs.utils.ItemExamines;
import com.rs.utils.Logger;
import com.rs.utils.Utils;

public class ButtonHandler {

	public static void handleButtons(final Player player, InputStream stream, int packetId) {
		int interfaceHash = stream.readIntV2();
		int interfaceId = interfaceHash >> 16;
		if (Utils.getInterfaceDefinitionsSize() <= interfaceId) {
			// hack, or server error or client error
			// player.getSession().getChannel().close();
			return;
		}
		if (!World.containsLobbyPlayer(player.getUsername())) {
			if (player.isDead() || !player.getInterfaceManager().containsInterface(interfaceId)) {
				return;
			}
		}
		final int componentId = interfaceHash - (interfaceId << 16);
		if (componentId != 65535 && Utils.getInterfaceDefinitionsComponentsSize(interfaceId) <= componentId) {
			// hack, or server error or client error
			// player.getSession().getChannel().close();
			return;
		}
		final int slotId2 = stream.readUnsignedShort128();
		final int slotId = stream.readUnsignedShortLE128();
		if (!player.getControlerManager().processButtonClick(interfaceId, componentId, slotId, packetId))
			return;
		if (interfaceId == 105 || interfaceId == 107) {
			GrandExchange.handleButtons(player, interfaceId, slotId, componentId, packetId);
		}
		if (interfaceId == 548 || interfaceId == 746) {
			if ((interfaceId == 548 && componentId == 148) || (interfaceId == 746 && componentId == 199)) {
				if (player.getInterfaceManager().containsScreenInter() || player.getInterfaceManager().containsInventoryInter()) {
					// TODO cant open sound
					player.getPackets().sendGameMessage("Please finish what you're doing before opening the world map.");
					return;
				}
				// world map open
				player.getPackets().sendWindowsPane(755, 0);
				int posHash = player.getX() << 14 | player.getY();
				player.getPackets().sendGlobalConfig(622, posHash); // map open
				// center
				// pos
				player.getPackets().sendGlobalConfig(674, posHash); // player
				// position

				// Quests

			} else if ((interfaceId == 548 && componentId == 17) || (interfaceId == 746 && componentId == 54)) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getSkills().switchXPDisplay();
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getSkills().switchXPPopup();
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getSkills().setupXPCounter();
				
			}else if ((interfaceId == 746 && componentId == 207) || (interfaceId == 548 && componentId == 159)
					|| (interfaceId == 548 && componentId == 194)) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
					if (!player.getInterfaceManager().containsScreenInter()) {
						player.getPackets().sendRunScript(5557, 1);
						player.refreshMoneyPouch();
					} else
						player.getPackets().sendGameMessage("Please finish what you are doing first.");
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET){
					player.getTemporaryAttributes().put("remove_X_money", 995);
					player.getTemporaryAttributes().put("remove_money", Boolean.TRUE);
					player.getPackets().sendRunScript(108, new Object[] { "                          Your money pouch contains " + player.money + " coins." + "                           How many would you like to withdraw?"});
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET){
					player.getPackets().sendGameMessage("Your money pouch currently contains " + player.money + " coins.");
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
					if (player.getInterfaceManager().containsScreenInter()) {
						player.getPackets()
						.sendGameMessage(
								"Please finish what you're doing before opening the price checker.");
						return;
					}
					player.stopAll();
					player.getPriceCheckManager().openPriceCheck();
				}
			}
}		
		// Jewelry Crafting
		if (interfaceId == 446) {
			int goldBars = player.getInventory().getNumerOf(2357);
			if (componentId == 82) { // Gold Ring
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_RING, new Item(2357), new Item(-1), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_RING, new Item(2357), new Item(-1), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_RING, new Item(2357), new Item(-1), goldBars));
				}
			} else if (componentId == 84) { // Sapphire Ring
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_RING, new Item(2357), new Item(1607), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_RING, new Item(2357), new Item(1607), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_RING, new Item(2357), new Item(1607), goldBars));
				}
			} else if (componentId == 86) { // Emerald Ring
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_RING, new Item(2357), new Item(1605), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_RING, new Item(2357), new Item(1605), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_RING, new Item(2357), new Item(1605), goldBars));
				}
			} else if (componentId == 88) { // Ruby Ring
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_RING, new Item(2357), new Item(1603), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_RING, new Item(2357), new Item(1603), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_RING, new Item(2357), new Item(1603), goldBars));
				}
			} else if (componentId == 90) { // Diamond Ring
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_RING, new Item(2357), new Item(1601), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_RING, new Item(2357), new Item(1601), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_RING, new Item(2357), new Item(1601), goldBars));
				}
			} else if (componentId == 92) { // Dragonstone Ring
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_RING, new Item(2357), new Item(1615), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_RING, new Item(2357), new Item(1615), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_RING, new Item(2357), new Item(1615), goldBars));
				}
			} else if (componentId == 94) { // Onyx Ring
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_RING, new Item(2357), new Item(6573), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_RING, new Item(2357), new Item(6573), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_RING, new Item(2357), new Item(6573), goldBars));
				}
			} else if (componentId == 68) { // Gold Necklace
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_NECKLACE, new Item(2357), new Item(-1), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_NECKLACE, new Item(2357), new Item(-1), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_NECKLACE, new Item(2357), new Item(-1), goldBars));
				}
			} else if (componentId == 70) { // Sapphire Necklace
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_NECKLACE, new Item(2357), new Item(1607), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_NECKLACE, new Item(2357), new Item(1607), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_NECKLACE, new Item(2357), new Item(1607), goldBars));
				}
			} else if (componentId == 72) { // Emerald Necklace
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_NECKLACE, new Item(2357), new Item(1605), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_NECKLACE, new Item(2357), new Item(1605), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_NECKLACE, new Item(2357), new Item(1605), goldBars));
				}
			} else if (componentId == 74) { // Ruby Necklace
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_NECKLACE, new Item(2357), new Item(1603), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_NECKLACE, new Item(2357), new Item(1603), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_NECKLACE, new Item(2357), new Item(1603), goldBars));
				}
			} else if (componentId == 76) { // Diamond Necklace
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_NECKLACE, new Item(2357), new Item(1601), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_NECKLACE, new Item(2357), new Item(1601), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_NECKLACE, new Item(2357), new Item(1601), goldBars));
				}
			} else if (componentId == 78) { // Dragonstone Necklace
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_NECKLACE, new Item(2357), new Item(1615), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_NECKLACE, new Item(2357), new Item(1615), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_NECKLACE, new Item(2357), new Item(1615), goldBars));
				}
			} else if (componentId == 80) { // Onyx Necklace
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_NECKLACE, new Item(2357), new Item(6573), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_NECKLACE, new Item(2357), new Item(6573), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_NECKLACE, new Item(2357), new Item(6573), goldBars));
				}
			} else if (componentId == 53) { // Gold Amulet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_AMULET, new Item(2357), new Item(-1), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_AMULET, new Item(2357), new Item(-1), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_AMULET, new Item(2357), new Item(-1), goldBars));
				}
			} else if (componentId == 55) { // Sapphire Amulet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_AMULET, new Item(2357), new Item(1607), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_AMULET, new Item(2357), new Item(1607), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_AMULET, new Item(2357), new Item(1607), goldBars));
				}
			} else if (componentId == 57) { // Emerald Amulet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_AMULET, new Item(2357), new Item(1605), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_AMULET, new Item(2357), new Item(1605), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_AMULET, new Item(2357), new Item(1605), goldBars));
				}
			} else if (componentId == 59) { // Ruby Amulet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_AMULET, new Item(2357), new Item(1603), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_AMULET, new Item(2357), new Item(1603), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_AMULET, new Item(2357), new Item(1603), goldBars));
				}
			} else if (componentId == 61) { // Diamond Amulet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_AMULET, new Item(2357), new Item(1601), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_AMULET, new Item(2357), new Item(1601), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_AMULET, new Item(2357), new Item(1601), goldBars));
				}
			} else if (componentId == 63) { // Dragonstone Amulet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_AMULET, new Item(2357), new Item(1615), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_AMULET, new Item(2357), new Item(1615), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_AMULET, new Item(2357), new Item(1615), goldBars));
				}
			} else if (componentId == 65) { // Onyx Amulet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_AMULET, new Item(2357), new Item(6573), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_AMULET, new Item(2357), new Item(6573), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_AMULET, new Item(2357), new Item(6573), goldBars));
				}
			} else if (componentId == 33) { // Gold Bracelet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_BRACELET, new Item(2357), new Item(-1), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_BRACELET, new Item(2357), new Item(-1), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.GOLD_BRACELET, new Item(2357), new Item(-1), goldBars));
				}
			} else if (componentId == 35) { // Sapphire Bracelet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_BRACELET, new Item(2357), new Item(1607), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_BRACELET, new Item(2357), new Item(1607), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.SAPPHIRE_BRACELET, new Item(2357), new Item(1607), goldBars));
				}
			} else if (componentId == 37) { // Emerald Bracelet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_BRACELET, new Item(2357), new Item(1605), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_BRACELET, new Item(2357), new Item(1605), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.EMERALD_BRACELET, new Item(2357), new Item(1605), goldBars));
				}
			} else if (componentId == 39) { // Ruby Bracelet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_BRACELET, new Item(2357), new Item(1603), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_BRACELET, new Item(2357), new Item(1603), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.RUBY_BRACELET, new Item(2357), new Item(1603), goldBars));
				}
			} else if (componentId == 41) { // Diamond Bracelet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_BRACELET, new Item(2357), new Item(1601), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_BRACELET, new Item(2357), new Item(1601), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DIAMOND_BRACELET, new Item(2357), new Item(1601), goldBars));
				}
			} else if (componentId == 43) { // Dragonstone Bracelet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_BRACELET, new Item(2357), new Item(1615), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_BRACELET, new Item(2357), new Item(1615), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.DRAGONSTONE_BRACELET, new Item(2357), new Item(1615), goldBars));
				}
			} else if (componentId == 45) { // Onyx Bracelet
				if (packetId == 14) { // Make 1
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_BRACELET, new Item(2357), new Item(6573), 1));
				} else if (packetId == 67) { // Make 5
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_BRACELET, new Item(2357), new Item(6573), 5));
				} else if (packetId == 5) { // Make all
					player.getActionManager().setAction(new JewelryCrafting(JewerlyData.ONYX_BRACELET, new Item(2357), new Item(6573), goldBars));
				}
			}
		}

		if (interfaceId == 375) {
			player.getInterfaceManager().closeInventoryInterface();
			player.unlock();
			player.getAppearence().transformIntoNPC(-1);
			player.getTemporaryAttributes().remove("RingNPC");
			player.setNextAnimation(new Animation(14884));
			return;
		}
		if (interfaceId == 940) {
		DungeonRewards.handleButtons(player, componentId, slotId, packetId);
		}
		if (interfaceId == 1312) {
			if (componentId == 35) {
			player.closeInterfaces();					
			player.getDialogueManager().startDialogue("Teleporter");
		} else if (componentId == 43) {
			player.closeInterfaces();
			player.getDialogueManager().startDialogue("Shops");
		} else if (componentId == 51) {
			player.closeInterfaces();
			player.getDialogueManager().startDialogue("Droplog");
		} else if (componentId == 59) {
			player.closeInterfaces();
			player.getPackets().sendOpenURL("http://www.Phoenix.com/");
		} else if (componentId == 67) {
			player.closeInterfaces();
			player.getPackets().sendOpenURL("http://www.Phoenix.com/vote/");
		} else if (componentId == 75) {
			player.closeInterfaces();
			player.getPackets().sendOpenURL("http://www.Phoenix.com/donate/");
		} else if (componentId == 83) {	
			player.closeInterfaces();
			player.addFireImmune(6000);
			player.getPrayer().setPrayerpoints((int) ((int) (player.getSkills().getLevelForXp(Skills.PRAYER) * 10)));
			player.heal(1000);
			player.getSkills().restoreSummoning();
			player.getPackets().sendGameMessage("Your summoning, prayer and lifepoints are now restored.");
		} else if (componentId == 99) 
			player.closeInterfaces();
		}
		if (interfaceId == 1019) {
			if (componentId == 18) {
				player.getInterfaceManager().sendInterface(1082);
				for (int i = 0; i < 192; i++) {
					player.getPackets().sendIComponentText(1082, i, "");
				}
				player.getPackets().sendIComponentText(1082, 159, "Quests");
				player.getPackets().sendIComponentText(1082, 41, "Quest Name");
				player.getPackets().sendIComponentText(1082, 42, "About");
				player.getPackets().sendIComponentText(1082, 11, "<col=0080ff>Click on the various View Quest buttons on the right to find out more about the quest. Completed quests are green, quests in progress are yellow, and unstarted quests are red.</col>");
				player.getPackets().sendIComponentText(1082, 40, "Peril of Ice Mountains");
				player.getPackets().sendIComponentText(1082, 41, (player.getQuestManager().completedQuest(Quests.PERIL_OF_ICE_MONTAINS) ? "<col=48ff00>Completed</col>" : player.getQuestManager().getQuestStage(Quests.PERIL_OF_ICE_MONTAINS) >= 1 ? "<col=ffff00>Started</col>" : "<col=ff0000>Not Started</col>"));
				player.getPackets().sendIComponentText(1082, 32, "Nomad's Requiem");
				player.getPackets().sendIComponentText(1082, 33, (player.getQuestManager().completedQuest(Quests.NOMADS_REQUIEM) ? "<col=48ff00>Completed</col>" : player.getQuestManager().getQuestStage(Quests.NOMADS_REQUIEM) >= 1 ? "<col=ffff00>Started</col>" : "<col=ff0000>Not Started</col>"));
				player.getPackets().sendIComponentText(1082, 34, "Lost City");
				player.getPackets().sendIComponentText(1082, 35, (player.getQuestManager().completedQuest(Quests.LOST_CITY) ? "<col=48ff00>Completed</col>" : player.getQuestManager().getQuestStage(Quests.LOST_CITY) >= 1 ? "<col=ffff00>Started</col>" : "<col=ff0000>Not Started</col>"));
				player.getPackets().sendIComponentText(1082, 36, "Dwarf Cannon");
				player.getPackets().sendIComponentText(1082, 37, (player.getQuestManager().completedQuest(Quests.DWARF_CANNON) ? "<col=48ff00>Completed</col>" : player.getQuestManager().getQuestStage(Quests.DWARF_CANNON) >= 1 ? "<col=ffff00>Started</col>" : "<col=ff0000>Not Started</col>"));
				player.getPackets().sendIComponentText(1082, 38, "Recipe for Disaster");
				player.getPackets().sendIComponentText(1082, 39, (player.getQuestManager().completedQuest(Quests.RECIPE_FOR_DISASTER) ? "<col=48ff00>Completed</col>" : player.getQuestManager().getQuestStage(Quests.RECIPE_FOR_DISASTER) >= 1 ? "<col=ffff00>Started</col>" : "<col=ff0000>Not Started</col>"));
				player.getPackets().sendIComponentText(1082, 30, "StartTutorial");
				player.getPackets().sendIComponentText(1082, 31, (player.getQuestManager().completedQuest(Quests.STARTTUTORIAL) ? "<col=48ff00>Completed</col>" : player.getQuestManager().getQuestStage(Quests.RECIPE_FOR_DISASTER) >= 1 ? "<col=ffff00>Started</col>" : "<col=ff0000>Not Started</col>"));
			} else if (componentId == 16) {
				player.getPackets().sendGameMessage("Not implemented yet.");
			}
		}
		if (interfaceId == 297) {
			SandwichLadyHandler.handleButtons(player, componentId);
		}
		if (interfaceId == 1123) {
			CrystalSystem.handleButtons(player, componentId);
		}
		// squeal
		if (interfaceId == 1253) {
			if (componentId == 93) {
				SquealOfFortune.spin(player);
			} else if (componentId == 7) {
				player.getPackets().sendOpenURL("http://www.Phoenix.com/");
			} else if (componentId == 239) {
				SquealOfFortune.closeSOF(player);
			} else if (componentId == 192) {
				SquealOfFortune.claimItem(player);
				player.closeInterfaces();
			} else if (componentId == 273) {
				SquealOfFortune.claimItem(player);
				SquealOfFortune.openSOF(player);
			} else if (componentId == 258) {
				SquealOfFortune.claimItem(player);
				SquealOfFortune.closeSOF(player);
			} else if (componentId == 106)
				SquealOfFortune.closeSOF(player);
		}

		/* SLAYER POINTS */
		if (interfaceId == 164) {
			if (componentId == 16) {
				player.getInterfaceManager().sendInterface(163);
				player.getPackets().sendIComponentText(163, 18, "" + player.getSlayerPoints());

				// Points
				player.getPackets().sendIComponentText(163, 29, "100 points"); // Learn
																				// to
																				// make
																				// broads
				player.getPackets().sendIComponentText(163, 30, "100 points"); // Learn
																				// to
																				// make
																				// ring
																				// of
																				// slaying
				player.getPackets().sendIComponentText(163, 31, "200 points"); // Learn
																				// to
																				// make
																				// slayer
																				// helmet
				player.getPackets().sendIComponentText(163, 25, (player.learnBroad ? "(Already learned)" : ""));
				player.getPackets().sendIComponentText(163, 26, (player.learnRing ? "(Already learned)" : ""));
				player.getPackets().sendIComponentText(163, 27, (player.learnHelm ? "(Already learned)" : ""));
			} else if (componentId == 17) {
				player.getInterfaceManager().sendInterface(161);
				player.getPackets().sendIComponentText(161, 19, "" + player.getSlayerPoints());
			} else if (componentId == 24) { // Slayer XP
				if (player.getSlayerPoints() >= 50) {
					player.getSkills().addXp(Skills.SLAYER, 10000);
					player.getPackets().sendGameMessage("You buy 1,000,000 Slayer experience.");
					player.setSlayerPoints(player.getSlayerPoints() - 50);
					player.getPackets().sendIComponentText(164, 20, "" + player.getSlayerPoints());
				} else {
					player.getPackets().sendGameMessage("You do not have enough slayer points.");
				}
			} else if (componentId == 26) { // Ring of slaying
				if (player.getSlayerPoints() >= 10) {
					if (player.getInventory().hasFreeSlots()) {
						player.getInventory().addItem(13281, 1);
						player.getPackets().sendGameMessage("You buy a ring of slaying.");
						player.setSlayerPoints(player.getSlayerPoints() - 10);
						player.getPackets().sendIComponentText(164, 20, "" + player.getSlayerPoints());
					}
				} else {
					player.getPackets().sendGameMessage("You do not have enough slayer points.");
				}
			} else if (componentId == 28) { // Slayer dart runes
				if (player.getSlayerPoints() >= 18) {
					if (player.getInventory().hasFreeSlots()) {
						player.getInventory().addItem(560, 250);
						player.getInventory().addItem(556, 750);
						player.getPackets().sendGameMessage("You buy some Slayer Dart runes.");
						player.setSlayerPoints(player.getSlayerPoints() - 18);
						player.getPackets().sendIComponentText(164, 20, "" + player.getSlayerPoints());
					}
				} else {
					player.getPackets().sendGameMessage("You do not have enough slayer points.");
				}
			} else if (componentId == 37) { // Broad bolts
				if (player.getSlayerPoints() >= 18) {
					if (player.getInventory().hasFreeSlots()) {
						player.getInventory().addItem(13280, 250);
						player.getPackets().sendGameMessage("You buy some Broad-tipped bolts.");
						player.setSlayerPoints(player.getSlayerPoints() - 18);
						player.getPackets().sendIComponentText(164, 20, "" + player.getSlayerPoints());
					}
				} else {
					player.getPackets().sendGameMessage("You do not have enough slayer points.");
				}
			} else if (componentId == 39) { // Broad arrows
				if (player.getSlayerPoints() >= 18) {
					if (player.getInventory().hasFreeSlots()) {
						player.getInventory().addItem(4160, 250);
						player.getPackets().sendGameMessage("You buy some Broad arrows.");
						player.setSlayerPoints(player.getSlayerPoints() - 18);
						player.getPackets().sendIComponentText(164, 20, "" + player.getSlayerPoints());
					}
				} else {
					player.getPackets().sendGameMessage("You do not have enough slayer points.");
				}
			}
		}

		if (interfaceId == 163) {
			if (componentId == 15) {
				player.getInterfaceManager().sendInterface(164);
				player.getPackets().sendIComponentText(164, 20, "" + player.getSlayerPoints());

				// Points
				player.getPackets().sendIComponentText(164, 32, "50 points"); // Slayer
																				// XP
																				// (1M)
				player.getPackets().sendIComponentText(164, 33, "10 points"); // Ring
																				// of
																				// slaying
				player.getPackets().sendIComponentText(164, 36, "18 points"); // Slayer
																				// dart
																				// runes
				player.getPackets().sendIComponentText(164, 34, "18 points"); // Broad
																				// bolts
				player.getPackets().sendIComponentText(164, 35, "18 points"); // Broad
																				// arrows
			} else if (componentId == 14) {
				player.getInterfaceManager().sendInterface(161);
				player.getPackets().sendIComponentText(161, 19, "" + player.getSlayerPoints());
			} else if (componentId == 24) { // Learn slayer helm
				if (player.getSlayerPoints() >= 200) {
					player.learnHelm = true;
					player.setSlayerPoints(player.getSlayerPoints() - 200);
					player.getPackets().sendIComponentText(163, 18, "" + player.getSlayerPoints());
					player.getPackets().sendIComponentText(163, 27, (player.learnHelm ? "(Already learned)" : ""));
					player.getPackets().sendGameMessage("The secret is yours. You can now combine a black mask, face mask, spiny helm, nosepeg, and earmuffs into one useful item.");
				} else {
					player.getPackets().sendGameMessage("You do not have enough slayer points.");
				}
			}
		}

		if (interfaceId == 161) {
			if (componentId == 15) {
				player.getInterfaceManager().sendInterface(164);
				player.getPackets().sendIComponentText(164, 20, "" + player.getSlayerPoints());

				// Points
				player.getPackets().sendIComponentText(164, 32, "50 points"); // Slayer
																				// XP
																				// (1M)
				player.getPackets().sendIComponentText(164, 33, "10 points"); // Ring
																				// of
																				// slaying
				player.getPackets().sendIComponentText(164, 36, "18 points"); // Slayer
																				// dart
																				// runes
				player.getPackets().sendIComponentText(164, 34, "18 points"); // Broad
																				// bolts
				player.getPackets().sendIComponentText(164, 35, "18 points"); // Broad
																				// arrows
			} else if (componentId == 14) {
				player.getInterfaceManager().sendInterface(163);
				player.getPackets().sendIComponentText(163, 18, "" + player.getSlayerPoints());

				// Points
				player.getPackets().sendIComponentText(163, 29, "100 points"); // Learn
																				// to
																				// make
																				// broads
				player.getPackets().sendIComponentText(163, 30, "100 points"); // Learn
																				// to
																				// make
																				// ring
																				// of
																				// slaying
				player.getPackets().sendIComponentText(163, 31, "200 points"); // Learn
																				// to
																				// make
																				// slayer
																				// helmet
				player.getPackets().sendIComponentText(163, 25, (player.learnBroad ? "(Already learned)" : ""));
				player.getPackets().sendIComponentText(163, 26, (player.learnRing ? "(Already learned)" : ""));
				player.getPackets().sendIComponentText(163, 27, (player.learnHelm ? "(Already learned)" : ""));
			} else if (componentId == 23) {
				if (player.getSlayerPoints() >= 30 && player.getTask() != null) {
					player.setTask(null);
					player.setSlayerPoints(player.getSlayerPoints() - 30);
					player.getPackets().sendIComponentText(161, 19, "" + player.getSlayerPoints());
					player.getPackets().sendGameMessage("You have reset your task, you may choose another.");
				} else if (player.getTask() == null) {
					player.getPackets().sendGameMessage("You already don't have a task!");
				} else {
					player.getPackets().sendGameMessage("You do not have enough slayer points.");
				}
			} else if (componentId == 24) {
				player.getPackets().sendGameMessage("This feature is currently unavailable.");
			}
		}
		/* SLAYER POINTS */

		// construction
		if (interfaceId == 397) {
			ConstructFurniture.handleButtons(player, componentId);
		}

		if (interfaceId == 403) {
			MakePlank.handleButtons(player, componentId, packetId);
		}

		if (interfaceId == 1139) {
			if (componentId == 18) {
				SquealOfFortune.openSOF(player);
			}
		}

		if (interfaceId == 1252) {
			if (componentId == 3) {
				SquealOfFortune.openSOF(player);
			} else if (componentId == 5) {
				player.getPackets().closeInterface(player.getInterfaceManager().hasRezizableScreen() ? 11 : 0);
				player.getPackets().sendGameMessage("The Squeal of Fortune icon will show again upon login.");
			}
		}
		if (interfaceId == 548 && componentId == 68) {
			player.getPackets().sendIComponentText(1139, 10, " " + player.getSpins() + " ");
		}

		if (interfaceId == 34) {
				if (packetId == 55) {
					if (componentId == 9) {
						player.getNotes().remove(slotId);
					}
				} else if (packetId == 14) {
					if (componentId == 3) {
						player.getTemporaryAttributes().put("entering_note", Boolean.TRUE); 
						player.getPackets().sendInputLongTextScript("Enter a new note:"); 
					} else if (componentId == 8) {
						player.sendMessage("Please right click the note you wish to delete instead.");
					}
				} else if (packetId == 67) {
					Note note = (Note) player.getCurNotes().get(slotId);
					player.getTemporaryAttributes().put("editing_note", Boolean.TRUE); 
					player.getTemporaryAttributes().put("noteToEdit", note); 
					player.getPackets().sendInputLongTextScript("Enter a new note:"); 
				} else if (packetId == 5) {
					if (componentId == 9) {
						Note note = (Note)  player.getCurNotes().get(slotId); 
						int color = note.getColour() == 0 ? 1 :
									note.getColour() == 1 ? 2 :
									note.getColour() == 2 ? 3 : 0;
							note.setColour(color);
						player.getNotes().refresh(note);
					}
				}
				return;
		} else if (interfaceId == 1263) {
			int skillId;
			if (componentId == 13) { // Attack
				skillId = Skills.ATTACK;
				player.getPackets().sendIComponentText(1263, 11, "Attack: " + NumberFormat.getInstance().format(AncientEffigies.dragonkinFormula(player, skillId)) + " XP");
				// AncientEffigies.dragonkinLamp(player, skillId);
			} else if (componentId == 14) { // Magic
				skillId = Skills.MAGIC;
			} else if (componentId == 15) { // Mining
				skillId = Skills.MINING;
			} else if (componentId == 44) { // Close
				player.closeInterfaces();
			}
		} else if (interfaceId == 182) {
			if (player.getInterfaceManager().containsInventoryInter())
				return;
			if (componentId == 6 || componentId == 13)
				if (!player.hasFinished())
					player.logout(componentId == 6);
			// Hiscores.saveHighScore(player);
		} else if (interfaceId == 1165) {
			// if (componentId == 22)
			// Summoning.closeDreadnipInterface(player);
		} else if (interfaceId == 880) {
			if (componentId >= 7 && componentId <= 19)
				Familiar.setLeftclickOption(player, (componentId - 7) / 2);
			else if (componentId == 21)
				Familiar.confirmLeftOption(player);
			else if (componentId == 25)
				Familiar.setLeftclickOption(player, 7);
		} else if (interfaceId == 662) {
			if (player.getFamiliar() == null) {
				if (player.getPet() == null) {
					return;
				}
				if (componentId == 49)
					player.getPet().call();
				else if (componentId == 51)
					player.getDialogueManager().startDialogue("DismissD");
				return;
			}
			if (componentId == 49)
				player.getFamiliar().call();
			else if (componentId == 51)
				player.getDialogueManager().startDialogue("DismissD");
			else if (componentId == 67)
				player.getFamiliar().takeBob();
			else if (componentId == 69)
				player.getFamiliar().renewFamiliar();
			else if (componentId == 74) {
				if (player.getFamiliar().getSpecialAttack() == SpecialAttack.CLICK)
					player.getFamiliar().setSpecial(true);
				if (player.getFamiliar().hasSpecialOn())
					player.getFamiliar().submitSpecial(player);
			}
		} else if (interfaceId == 747) {
			if (componentId == 8) {
				Familiar.selectLeftOption(player);
			} else if (player.getPet() != null) {
				if (componentId == 11 || componentId == 20) {
					player.getPet().call();
				} else if (componentId == 12 || componentId == 21) {
					player.getDialogueManager().startDialogue("DismissD");
				} else if (componentId == 10 || componentId == 19) {
					player.getPet().sendFollowerDetails();
				}
			} else if (player.getFamiliar() != null) {
				if (componentId == 11 || componentId == 20)
					player.getFamiliar().call();
				else if (componentId == 12 || componentId == 21)
					player.getDialogueManager().startDialogue("DismissD");
				else if (componentId == 13 || componentId == 22)
					player.getFamiliar().takeBob();
				else if (componentId == 14 || componentId == 23)
					player.getFamiliar().renewFamiliar();
				else if (componentId == 19 || componentId == 10)
					player.getFamiliar().sendFollowerDetails();
				else if (componentId == 18) {
					if (player.getFamiliar().getSpecialAttack() == SpecialAttack.CLICK)
						player.getFamiliar().setSpecial(true);
					if (player.getFamiliar().hasSpecialOn())
						player.getFamiliar().submitSpecial(player);
				}
			}
		} else if (interfaceId == 309)
			PlayerLook.handleHairdresserSalonButtons(player, componentId, slotId);
		else if (interfaceId == 729)
			PlayerLook.handleThessaliasMakeOverButtons(player, componentId, slotId);
		else if (interfaceId == 187) {
			if (componentId == 1) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getMusicsManager().playAnotherMusic(slotId / 2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getMusicsManager().sendHint(slotId / 2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getMusicsManager().addToPlayList(slotId / 2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getMusicsManager().removeFromPlayList(slotId / 2);
			} else if (componentId == 4)
				player.getMusicsManager().addPlayingMusicToPlayList();
			else if (componentId == 10)
				player.getMusicsManager().switchPlayListOn();
			else if (componentId == 11)
				player.getMusicsManager().clearPlayList();
			else if (componentId == 13)
				player.getMusicsManager().switchShuffleOn();
		} else if (interfaceId == 275) {
			if (componentId == 14) {
				player.getPackets().sendOpenURL(Settings.WEBSITE_LINK);
			}
		} else if ((interfaceId == 590 && componentId == 8) || interfaceId == 464) {
			player.getEmotesManager().useBookEmote(interfaceId == 464 ? componentId : EmotesManager.getId(slotId, packetId));
		} else if (interfaceId == 192) {
			if (componentId == 2)
				player.getCombatDefinitions().switchDefensiveCasting();
			else if (componentId == 7)
				player.getCombatDefinitions().switchShowCombatSpells();
			else if (componentId == 9)
				player.getCombatDefinitions().switchShowTeleportSkillSpells();
			else if (componentId == 11)
				player.getCombatDefinitions().switchShowMiscallaneousSpells();
			else if (componentId == 13)
				player.getCombatDefinitions().switchShowSkillSpells();
			else if (componentId >= 15 & componentId <= 17)
				player.getCombatDefinitions().setSortSpellBook(componentId - 15);
			else
				Magic.processNormalSpell(player, componentId, packetId);
		} else if (interfaceId == 334) {
			if (componentId == 22)
				player.closeInterfaces();
			else if (componentId == 21)
				player.getTrade().accept(false);
		} else if (interfaceId == 335) {
			if (componentId == 18)
				player.getTrade().accept(true);
			if (componentId == 20)
				player.closeInterfaces();
			/*else if (componentId == 53) {
				player.getTemporaryAttributes().put("add_To_Trade", 995);
				player.getTemporaryAttributes().put("add_coins_to_trade", Boolean.TRUE);
				player.getPackets().sendRunScript(108, new Object[] { "                          Your money pouch contains " +Player.getFormattedNumber(player.money) + " coins." + "                           How much would you like to offer?"});
			}*/
			else if (componentId == 32) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getTrade().removeItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getTrade().removeItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getTrade().removeItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getTrade().removeItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("trade_item_X_Slot", slotId);
					player.getTemporaryAttributes().put("trade_isRemove", Boolean.TRUE);
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				} else if(packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET) {
					player.getTrade().sendValue(slotId);
			}else if(packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getInventory().sendExamine(slotId);
			} else if (componentId == 35) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getTrade().sendValue(slotId, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getTrade().sendExamine(slotId, true);
			}
		} else if (interfaceId == 336) {
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getTrade().addItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getTrade().addItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getTrade().addItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getTrade().addItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getPackets().sendGameMessage("A " + new Item(slotId2, 1).getDefinitions().getName().toLowerCase() + "'s value is " + ItemDefinitions.getItemDefinitions(slotId2).getValue() + " gold.");

				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("trade_item_X_Slot", slotId);
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getTrade().sendValue(slotId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if (interfaceId == 300) {
			ForgingInterface.handleIComponents(player, componentId);
		} else if (interfaceId == 206) {
			if (componentId == 15) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getPriceCheckManager().removeItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getPriceCheckManager().removeItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getPriceCheckManager().removeItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getPriceCheckManager().removeItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("pc_item_X_Slot", slotId);
					player.getTemporaryAttributes().put("pc_isRemove", Boolean.TRUE);
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				}
			}
		}  else if (interfaceId == 666) {
			switch (componentId) {
			case 18:
				Summoning.sendInterface(player);
				break;
			case 16:
				switch (packetId) {
				case 14:
					SummoningScroll.createScroll(player, slotId2, 1);
					break;
				case 67: // 5
					SummoningScroll.createScroll(player, slotId2, 5);
					break;
				case 5: // 10
					SummoningScroll.createScroll(player, slotId2, 10);
					break;
				case 55: // all
					SummoningScroll.createScroll(player, slotId2, 28);
					break;
				case 68: // x
					player.getTemporaryAttributes().put("item1", slotId2);
					player.getTemporaryAttributes().put("sum1",
							Integer.valueOf(0));
					player.getPackets()
							.sendRunScript(
									108,
									new Object[] { "How many would you like to make? " });
					break;
				}
				break;
			}
		} else if (interfaceId == 672) {
			if (componentId == 19)
				SummoningScroll.sendInterface(player);
			if (componentId == 16) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					Summoning.createPouch(player, slotId2, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					Summoning.createPouch(player, slotId2, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					Summoning.createPouch(player, slotId2, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					Summoning.createPouch(player, slotId2, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					Summoning.createPouch(player, slotId2, 28);// x
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET) {
					player.getPackets().sendGameMessage("You currently need " + ItemDefinitions.getItemDefinitions(slotId2).getCreateItemRequirements());
				}
			}
		} else if (interfaceId == 207) {
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getPriceCheckManager().addItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getPriceCheckManager().addItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getPriceCheckManager().addItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getPriceCheckManager().addItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("pc_item_X_Slot", slotId);
					player.getTemporaryAttributes().remove("pc_isRemove");
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if (interfaceId == 665) {
			if (player.getFamiliar() == null || player.getFamiliar().getBob() == null)
				return;
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getFamiliar().getBob().addItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getFamiliar().getBob().addItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getFamiliar().getBob().addItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getFamiliar().getBob().addItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("bob_item_X_Slot", slotId);
					player.getTemporaryAttributes().remove("bob_isRemove");
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if (interfaceId == 506) {
			switch (componentId) {
			case 2:// My Account
				player.getDialogueManager().startDialogue("MyAccount");
				break;
			case 4:// Achievement Logs
				player.getDialogueManager().startDialogue("Achievements");
				break;
			case 6:// Slayer task
				if (player.getTask() != null) {
					player.getPackets().sendGameMessage("Your current assignment is: " + player.getTask().getName().toLowerCase() + "s; only " + player.getTask().getTaskAmount() + " more to go.");
				} else {
					player.getPackets().sendGameMessage("You need something new to hunt; return to a Slayer master.");
				}
				break;
			case 8:// Switch Magic/Prayer
				player.getDialogueManager().startDialogue("Switching");
				break;
			case 10:// PvP Teleports
				player.getDialogueManager().startDialogue("PvPTeleports");
				break;
			case 12:// XP Lock
				player.getPackets().sendIComponentText(506, 12, (player.isXpLocked() ? "Lock" : "Unlock") + " XP");
				player.setXpLocked(player.isXpLocked() ? false : true);
				player.getPackets().sendGameMessage("You have " + (player.isXpLocked() ? "Locked" : "Unlocked") + " your xp.");
				break;
			case 14:// Skilling Locations
				player.getDialogueManager().startDialogue("SkillingTeleports");
				break;
			}
		} else if (interfaceId == 671) {
			if (player.getFamiliar() == null || player.getFamiliar().getBob() == null)
				return;
			if (componentId == 27) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getFamiliar().getBob().removeItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getFamiliar().getBob().removeItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getFamiliar().getBob().removeItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getFamiliar().getBob().removeItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("bob_item_X_Slot", slotId);
					player.getTemporaryAttributes().put("bob_isRemove", Boolean.TRUE);
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				}
			} else if (componentId == 29)
				player.getFamiliar().takeBob();
		} else if (interfaceId == 916) {
			SkillsDialogue.handleSetQuantityButtons(player, componentId);
		} else if (interfaceId == 193) {
			if (componentId == 5)
				player.getCombatDefinitions().switchShowCombatSpells();
			else if (componentId == 7)
				player.getCombatDefinitions().switchShowTeleportSkillSpells();
			else if (componentId >= 9 && componentId <= 11)
				player.getCombatDefinitions().setSortSpellBook(componentId - 9);
			else if (componentId == 18)
				player.getCombatDefinitions().switchDefensiveCasting();
			else
				Magic.processAncientSpell(player, componentId, packetId);
		} else if (interfaceId == 430) {
			if (componentId == 5)
				player.getCombatDefinitions().switchShowCombatSpells();
			else if (componentId == 7)
				player.getCombatDefinitions().switchShowTeleportSkillSpells();
			else if (componentId == 9)
				player.getCombatDefinitions().switchShowMiscallaneousSpells();
			else if (componentId >= 11 & componentId <= 13)
				player.getCombatDefinitions().setSortSpellBook(componentId - 11);
			else if (componentId == 20)
				player.getCombatDefinitions().switchDefensiveCasting();
			else
				Magic.processLunarSpell(player, componentId, packetId);
		} else if (interfaceId == 261) {
			if (player.getInterfaceManager().containsInventoryInter())
				return;
			if (componentId == 22) {
				if (player.getInterfaceManager().containsScreenInter()) {
					player.getPackets().sendGameMessage("Please close the interface you have open before setting your graphic options.");
					return;
				}
				player.stopAll();
				player.getInterfaceManager().sendInterface(742);
			} else if (componentId == 12)
				player.switchAllowChatEffects();
			else if (componentId == 15)
				player.switchAcceptAid();
			else if (componentId == 13) { // chat setup
				player.getInterfaceManager().sendSettings(982);
			} else if (componentId == 14) {
				player.switchMouseButtons();
			} else if (componentId == 24) { // audio options
				player.getInterfaceManager().sendSettings(429);
			} else if (componentId == 26) {
				AdventurersLog.open(player);
			}
		} else if (interfaceId == 429) {
			if (componentId == 18)
				player.getInterfaceManager().sendSettings();
		} else if (interfaceId == 982) {
			if (componentId == 5)
				player.getInterfaceManager().sendSettings();
			else if (componentId == 41)
				player.setPrivateChatSetup(player.getPrivateChatSetup() == 0 ? 1 : 0);
			else if (componentId >= 49 && componentId <= 66)
				player.setPrivateChatSetup(componentId - 48);
			else if (componentId >= 72 && componentId <= 91)
				player.setFriendChatSetup(componentId - 72);
		} else if (interfaceId == 271) {
			WorldTasksManager.schedule(new WorldTask() {
				@Override
				public void run() {
					if (componentId == 8 || componentId == 42)
						player.getPrayer().switchPrayer(slotId);

					else if (componentId == 43 && player.getPrayer().isUsingQuickPrayer())
						player.getPrayer().switchSettingQuickPrayer();
				}
			});
		} else if (interfaceId == 320) {
			player.stopAll();
			int lvlupSkill = -1;
			int skillMenu = -1;
			switch (componentId) {
			case 150: // Attack
				skillMenu = 1;
				if (player.getTemporaryAttributes().remove("leveledUp[0]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 1);
				} else {
					lvlupSkill = 0;
					player.getPackets().sendConfig(1230, 10);
				}
				break;
			case 9: // Strength
				skillMenu = 2;
				if (player.getTemporaryAttributes().remove("leveledUp[2]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 2);
				} else {
					lvlupSkill = 2;
					player.getPackets().sendConfig(1230, 20);
				}
				break;
			case 22: // Defence
				skillMenu = 5;
				if (player.getTemporaryAttributes().remove("leveledUp[1]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 5);
				} else {
					lvlupSkill = 1;
					player.getPackets().sendConfig(1230, 40);
				}
				break;
			case 40: // Ranged
				skillMenu = 3;
				if (player.getTemporaryAttributes().remove("leveledUp[4]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 3);
				} else {
					lvlupSkill = 4;
					player.getPackets().sendConfig(1230, 30);
				}
				break;
			case 58: // Prayer
				if (player.getTemporaryAttributes().remove("leveledUp[5]") != Boolean.TRUE) {
					skillMenu = 7;
					player.getPackets().sendConfig(965, 7);
				} else {
					lvlupSkill = 5;
					player.getPackets().sendConfig(1230, 60);
				}
				break;
			case 71: // Magic
				if (player.getTemporaryAttributes().remove("leveledUp[6]") != Boolean.TRUE) {
					skillMenu = 4;
					player.getPackets().sendConfig(965, 4);
				} else {
					lvlupSkill = 6;
					player.getPackets().sendConfig(1230, 33);
				}
				break;
			case 84: // Runecrafting
				if (player.getTemporaryAttributes().remove("leveledUp[20]") != Boolean.TRUE) {
					skillMenu = 12;
					player.getPackets().sendConfig(965, 12);
				} else {
					lvlupSkill = 20;
					player.getPackets().sendConfig(1230, 100);
				}
				break;
			case 102: // Construction
				skillMenu = 22;
				if (player.getTemporaryAttributes().remove("leveledUp[21]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 22);
				} else {
					lvlupSkill = 21;
					player.getPackets().sendConfig(1230, 698);
				}
				break;
			case 145: // Hitpoints
				skillMenu = 6;
				if (player.getTemporaryAttributes().remove("leveledUp[3]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 6);
				} else {
					lvlupSkill = 3;
					player.getPackets().sendConfig(1230, 50);
				}
				break;
			case 15: // Agility
				skillMenu = 8;
				if (player.getTemporaryAttributes().remove("leveledUp[16]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 8);
				} else {
					lvlupSkill = 16;
					player.getPackets().sendConfig(1230, 65);
				}
				break;
			case 28: // Herblore
				skillMenu = 9;
				if (player.getTemporaryAttributes().remove("leveledUp[15]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 9);
				} else {
					lvlupSkill = 15;
					player.getPackets().sendConfig(1230, 75);
				}
				break;
			case 46: // Thieving
				skillMenu = 10;
				if (player.getTemporaryAttributes().remove("leveledUp[17]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 10);
				} else {
					lvlupSkill = 17;
					player.getPackets().sendConfig(1230, 80);
				}
				break;
			case 64: // Crafting
				skillMenu = 11;
				if (player.getTemporaryAttributes().remove("leveledUp[12]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 11);
				} else {
					lvlupSkill = 12;
					player.getPackets().sendConfig(1230, 90);
				}
				break;
			case 77: // Fletching
				skillMenu = 19;
				if (player.getTemporaryAttributes().remove("leveledUp[9]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 19);
				} else {
					lvlupSkill = 9;
					player.getPackets().sendConfig(1230, 665);
				}
				break;
			case 90: // Slayer
				skillMenu = 20;
				if (player.getTemporaryAttributes().remove("leveledUp[18]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 20);
				} else {
					lvlupSkill = 18;
					player.getPackets().sendConfig(1230, 673);
				}
				break;
			case 108: // Hunter
				skillMenu = 23;
				if (player.getTemporaryAttributes().remove("leveledUp[22]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 23);
				} else {
					lvlupSkill = 22;
					player.getPackets().sendConfig(1230, 689);
				}
				break;
			case 140: // Mining
				skillMenu = 13;
				if (player.getTemporaryAttributes().remove("leveledUp[14]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 13);
				} else {
					lvlupSkill = 14;
					player.getPackets().sendConfig(1230, 110);
				}
				break;
			case 135: // Smithing
				skillMenu = 14;
				if (player.getTemporaryAttributes().remove("leveledUp[13]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 14);
				} else {
					lvlupSkill = 13;
					player.getPackets().sendConfig(1230, 115);
				}
				break;
			case 34: // Fishing
				skillMenu = 15;
				if (player.getTemporaryAttributes().remove("leveledUp[10]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 15);
				} else {
					lvlupSkill = 10;
					player.getPackets().sendConfig(1230, 120);
				}
				break;
			case 52: // Cooking
				skillMenu = 16;
				if (player.getTemporaryAttributes().remove("leveledUp[7]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 16);
				} else {
					lvlupSkill = 7;
					player.getPackets().sendConfig(1230, 641);
				}
				break;
			case 130: // Firemaking
				skillMenu = 17;
				if (player.getTemporaryAttributes().remove("leveledUp[11]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 17);
				} else {
					lvlupSkill = 11;
					player.getPackets().sendConfig(1230, 649);
				}
				break;
			case 125: // Woodcutting
				skillMenu = 18;
				if (player.getTemporaryAttributes().remove("leveledUp[8]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 18);
				} else {
					lvlupSkill = 8;
					player.getPackets().sendConfig(1230, 660);
				}
				break;
			case 96: // Farming
				skillMenu = 21;
				if (player.getTemporaryAttributes().remove("leveledUp[19]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 21);
				} else {
					lvlupSkill = 19;
					player.getPackets().sendConfig(1230, 681);
				}
				break;
			case 114: // Summoning
				skillMenu = 24;
				if (player.getTemporaryAttributes().remove("leveledUp[23]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 24);
				} else {
					lvlupSkill = 23;
					player.getPackets().sendConfig(1230, 705);
				}
				break;
			case 120: // Dung
				skillMenu = 25;
				if (player.getTemporaryAttributes().remove("leveledUp[24]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 25);
				} else {
					lvlupSkill = 24;
					player.getPackets().sendConfig(1230, 705);
				}
				break;
			}

			/*
			 * player.getInterfaceManager().sendInterface( lvlupSkill != -1 ?
			 * 741 : 499);
			 */
			player.getInterfaceManager().sendScreenInterface(317, 1218);
			player.getPackets().sendInterface(false, 1218, 1, 1217); // seems to
																		// fix
			if (lvlupSkill != -1)
				LevelUp.switchFlash(player, lvlupSkill, false);
			if (skillMenu != -1)
				player.getTemporaryAttributes().put("skillMenu", skillMenu);
		} else if (interfaceId == 1218) {
			if ((componentId >= 33 && componentId <= 55) || componentId == 120 || componentId == 151 || componentId == 189)
				player.getPackets().sendInterface(false, 1218, 1, 1217); // seems
																			// to																	// fix
		} else if (interfaceId == 499) {
			int skillMenu = -1;
			if (player.getTemporaryAttributes().get("skillMenu") != null)
				skillMenu = (Integer) player.getTemporaryAttributes().get("skillMenu");
			if (componentId >= 10 && componentId <= 25)
				player.getPackets().sendConfig(965, ((componentId - 10) * 1024) + skillMenu);
			else if (componentId == 29)
				// close inter
				player.stopAll();

		} else if (interfaceId == 387) {
			if (player.getInterfaceManager().containsInventoryInter())
				return;
			if (componentId == 6) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
					int hatId = player.getEquipment().getHatId();
					if (hatId == 24437 || hatId == 24439 || hatId == 24440 || hatId == 24441) {
						player.getDialogueManager().startDialogue("FlamingSkull", player.getEquipment().getItem(Equipment.SLOT_HAT), -1);
						return;
					}
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
					ButtonHandler.sendRemove(player, Equipment.SLOT_HAT);
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_HAT);
			} else if (componentId == 9) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
					int capeId = player.getEquipment().getCapeId();
					if (capeId == 20769 || capeId == 20771) {
						player.getSkills().restoreSummoning();
						player.setNextAnimation(new Animation(8502));
						player.setNextGraphics(new Graphics(1308));
						player.getPackets().sendGameMessage("You restored your Summoning points with the Completionist cape!", true);
					}
				}
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					int capeId = player.getEquipment().getCapeId();
					if (capeId == 20769 || capeId == 20771)
						SkillCapeCustomizer.startCustomizing(player, capeId);
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
					int capeId = player.getEquipment().getCapeId();
					if (capeId == 20767)
						SkillCapeCustomizer.startCustomizing(player, capeId);
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_CAPE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_CAPE);
			} else if (componentId == 12) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
					int amuletId = player.getEquipment().getAmuletId();
					if (amuletId <= 1712 && amuletId >= 1706 || amuletId >= 10354 && amuletId <= 10361) {
						if (Magic.sendItemTeleportSpell(player, true, Transportation.EMOTE, Transportation.GFX, 4, new WorldTile(3087, 3496, 0))) {
							Item amulet = player.getEquipment().getItem(Equipment.SLOT_AMULET);
							if (amulet != null) {
								if (amuletId >= 10354 && amuletId <= 10361)
									amulet.setId(amulet.getId() + 2);
								else if (amuletId <= 1712 && amuletId >= 1706)
									amulet.setId(amulet.getId() - 2);
								player.getEquipment().refresh(Equipment.SLOT_AMULET);
							}
						}
					} else if (amuletId == 1704 || amuletId == 10352)
						player.getPackets().sendGameMessage("The amulet has ran out of charges. You need to recharge it if you wish it use it once more.");
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET) {
					int amuletId = player.getEquipment().getAmuletId();
					if (amuletId <= 1712 && amuletId >= 1706 || amuletId >= 10354 && amuletId <= 10361) {
						if (Magic.sendItemTeleportSpell(player, true, Transportation.EMOTE, Transportation.GFX, 4, new WorldTile(2918, 3176, 0))) {
							Item amulet = player.getEquipment().getItem(Equipment.SLOT_AMULET);
							if (amulet != null) {
								if (amuletId >= 10354 && amuletId <= 10361)
									amulet.setId(amulet.getId() + 2);
								else if (amuletId <= 1712 && amuletId >= 1706)
									amulet.setId(amulet.getId() - 2);
								player.getEquipment().refresh(Equipment.SLOT_AMULET);
							}
						}
					}
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
					int amuletId = player.getEquipment().getAmuletId();
					if (amuletId <= 1712 && amuletId >= 1706 || amuletId >= 10354 && amuletId <= 10361) {
						if (Magic.sendItemTeleportSpell(player, true, Transportation.EMOTE, Transportation.GFX, 4, new WorldTile(3105, 3251, 0))) {
							Item amulet = player.getEquipment().getItem(Equipment.SLOT_AMULET);
							if (amulet != null) {
								if (amuletId >= 10354 && amuletId <= 10361)
									amulet.setId(amulet.getId() + 2);
								else if (amuletId <= 1712 && amuletId >= 1706)
									amulet.setId(amulet.getId() - 2);
								player.getEquipment().refresh(Equipment.SLOT_AMULET);
							}
						}
					}
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					int amuletId = player.getEquipment().getAmuletId();
					if (amuletId <= 1712 && amuletId >= 1706 || amuletId >= 10354 && amuletId <= 10361) {
						if (Magic.sendItemTeleportSpell(player, true, Transportation.EMOTE, Transportation.GFX, 4, new WorldTile(3293, 3163, 0))) {
							Item amulet = player.getEquipment().getItem(Equipment.SLOT_AMULET);
							if (amulet != null) {
								if (amuletId >= 10354 && amuletId <= 10361)
									amulet.setId(amulet.getId() + 2);
								else if (amuletId <= 1712 && amuletId >= 1706)
									amulet.setId(amulet.getId() - 2);
								player.getEquipment().refresh(Equipment.SLOT_AMULET);
							}
						}
					}
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_AMULET);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_AMULET);
			} else if (componentId == 15) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_WEAPON);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_WEAPON);
			} else if (componentId == 18) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_CHEST);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_CHEST);
			} else if (componentId == 21) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_SHIELD);
				else if (componentId == 21 && packetId == 67 && player.getEquipment().getShieldId() == 11283 && player.DFS >= 1)
					Combat.hasDragonFire(player);//TODO
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_SHIELD);
			} else if (componentId == 24) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_LEGS);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_LEGS);
			} else if (componentId == 27) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_HANDS);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_HANDS);
			} else if (componentId == 30) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_FEET);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_FEET);
			} else if (componentId == 33) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_RING);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_RING);
			} else if (componentId == 36) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_ARROWS);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_ARROWS);
			} else if (componentId == 45) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
					ButtonHandler.sendRemove(player, Equipment.SLOT_AURA);
					player.getAuraManager().removeAura();
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_AURA);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getAuraManager().activate();
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getAuraManager().sendAuraRemainingTime();
			} else if (componentId == 37) {
				openEquipmentBonuses(player, false);
			} else if (componentId == 40) {
				player.stopAll();
				player.getInterfaceManager().sendInterface(17);
			} else if (componentId == 41) {
				player.stopAll();
				player.getInterfaceManager().sendInterface(1178);
				player.getPackets().sendConfig(2438, -1);
				player.getPackets().sendConfig(2439, -1);
			}
		} else if (interfaceId == 679 && packetId == 5 && player.getInventory().containsItem(11283, 1)) {
			InventoryOptionsHandler.DFS(player, slotId2, 11283);
		} else if (interfaceId == 1265) {
			Shop shop = (Shop) player.getTemporaryAttributes().get("Shop");
			if (shop == null)
				return;
			Integer slot = (Integer) player.getTemporaryAttributes().get("ShopSelectedSlot");
			boolean isBuying = (boolean) player.getTemporaryAttributes().get("shop_buying") == true;
			int amount = (int) player.getTemporaryAttributes().get("amount_shop");
			if (componentId == 20) {
				player.getTemporaryAttributes().put("ShopSelectedSlot", slotId);
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					shop.sendInfo(player, slotId, isBuying);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					shop.handleShop(player, slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					shop.handleShop(player, slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					shop.handleShop(player, slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					shop.handleShop(player, slotId, 50);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					shop.handleShop(player, slotId, 500);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					shop.sendExamine(player, slotId);
			} else if (componentId == 201) {
				if (slot == null)
					return;
				if (isBuying)
					shop.buy(player, slot, amount);
				else
					shop.sell(player, slot, amount);
			} else if (componentId == 29) {
				player.getTemporaryAttributes().put("shop_buying", false);
				player.getTemporaryAttributes().put("amount_shop", 1);
			} else if (componentId == 28) {
				player.getTemporaryAttributes().put("shop_buying", true);
				player.getTemporaryAttributes().put("amount_shop", 1);
			}
		} else if (interfaceId == 1266) {
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getInventory().sendExamine(slotId);
				else {
					Shop shop = (Shop) player.getTemporaryAttributes().get("Shop");
					if (shop == null)
						return;
					if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
						shop.sendValue(player, slotId);
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
						shop.sell(player, slotId, 1);
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
						shop.sell(player, slotId, 5);
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
						shop.sell(player, slotId, 10);
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
						shop.sell(player, slotId, 50);
				}
			}
		} else if (interfaceId == 640) {
			if (componentId == 18 || componentId == 22) {
				player.getTemporaryAttributes().put("WillDuelFriendly", true);
				player.getPackets().sendConfig(283, 67108864);
			} else if (componentId == 19 || componentId == 21) {
				player.getTemporaryAttributes().put("WillDuelFriendly", false);
				player.getPackets().sendConfig(283, 134217728);
			} else if (componentId == 20) {
				DuelControler.challenge(player);
			}
		} else if (interfaceId == 650) {
			if (componentId == 15) {
				player.stopAll();
				player.setNextWorldTile(new WorldTile(2974, 4384, player.getPlane()));
				player.getControlerManager().startControler("CorpBeastControler");
			} else if (componentId == 16)
				player.closeInterfaces();
		} else if (interfaceId == 667) {
			if (componentId == 14) {
				if (slotId >= 14)
					return;
				Item item = player.getEquipment().getItem(slotId);
				if (item == null)
					return;
				if (packetId == 3)
					player.getPackets().sendGameMessage(ItemExamines.getExamine(item));
				else if (packetId == 216) {
					sendRemove(player, slotId);
					ButtonHandler.refreshEquipBonuses(player);
				}
			} else if (componentId == 46 && player.getTemporaryAttributes().remove("Banking") != null) {
				player.getBank().openBank();
			}
		} else if (interfaceId == 670) {
			if (componentId == 0) {
				if (slotId >= player.getInventory().getItemsContainerSize())
					return;
				Item item = player.getInventory().getItem(slotId);
				if (item == null)
					return;
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
					if (sendWear(player, slotId, item.getId()))
						ButtonHandler.refreshEquipBonuses(player);
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if (interfaceId == Inventory.INVENTORY_INTERFACE) { // inventory
			if (componentId == 0) {
				if (slotId > 27 || player.getInterfaceManager().containsInventoryInter())
					return;
				Item item = player.getInventory().getItem(slotId);
				if (item == null || item.getId() != slotId2)
					return;
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					InventoryOptionsHandler.handleItemOption1(player, slotId, slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					InventoryOptionsHandler.handleItemOption2(player, slotId, slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					InventoryOptionsHandler.handleItemOption3(player, slotId, slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					InventoryOptionsHandler.handleItemOption4(player, slotId, slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					InventoryOptionsHandler.handleItemOption5(player, slotId, slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
					InventoryOptionsHandler.handleItemOption6(player, slotId, slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
					InventoryOptionsHandler.handleItemOption7(player, slotId, slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					InventoryOptionsHandler.handleItemOption8(player, slotId, slotId2, item);
			}
		} else if (interfaceId == 742) {
			if (componentId == 46) // close
				player.stopAll();
		} else if (interfaceId == 1253) {
			if (componentId == 0) // close
				player.stopAll();
		} else if (interfaceId == 743) {
			if (componentId == 20) // close
				player.stopAll();
		} else if (interfaceId == 741) {
			if (componentId == 9) // close
				player.stopAll();
		} else if (interfaceId == 749) {
			if (componentId == 4) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) // activate
					player.getPrayer().switchQuickPrayers();
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) // switch
					player.getPrayer().switchSettingQuickPrayer();
			}
		} else if (interfaceId == 750) {
			if (componentId == 4) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
					player.toogleRun(player.isResting() ? false : true);
					if (player.isResting())
						player.stopAll();
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
					if (player.isResting()) {
						player.stopAll();
						return;
					}
					long currentTime = Utils.currentTimeMillis();
					if (player.getEmotesManager().getNextEmoteEnd() >= currentTime) {
						player.getPackets().sendGameMessage("You can't rest while perfoming an emote.");
						return;
					}
					if (player.getLockDelay() >= currentTime) {
						player.getPackets().sendGameMessage("You can't rest while perfoming an action.");
						return;
					}
					player.stopAll();
					player.getActionManager().setAction(new Rest());
				}
			}
		} else if (interfaceId == 11) {
			if (componentId == 17) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getBank().depositItem(slotId, 1, false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getBank().depositItem(slotId, 5, false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getBank().depositItem(slotId, 10, false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getBank().depositItem(slotId, Integer.MAX_VALUE, false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("bank_item_X_Slot", slotId);
					player.getTemporaryAttributes().remove("bank_isWithdraw");
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getInventory().sendExamine(slotId);
			} else if (componentId == 18)
				player.getBank().depositAllInventory(false);
			else if (componentId == 20)
				player.getBank().depositAllEquipment(false);
		} else if (interfaceId == 762) {
			if (componentId == 15)
				player.getBank().switchInsertItems();
			else if (componentId == 19)
				player.getBank().switchWithdrawNotes();
			else if (componentId == 33)
				player.getBank().depositAllInventory(true);
		//	else if (componentId == 35)
				//player.getBank().switchWithMoneyPouch();
			else if (componentId == 37)
				player.getBank().depositAllEquipment(true);
			else if (componentId == 46) {
				player.closeInterfaces();
				player.getInterfaceManager().sendInterface(767);
				player.setCloseInterfacesEvent(new Runnable() {
					@Override
					public void run() {
						player.getBank().openBank();
					}
				});
			} else if (componentId >= 46 && componentId <= 64) {
				int tabId = 9 - ((componentId - 46) / 2);
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getBank().setCurrentTab(tabId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getBank().collapse(tabId);
			} else if (componentId == 95) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getBank().withdrawItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getBank().withdrawItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getBank().withdrawItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getBank().withdrawLastAmount(slotId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("bank_item_X_Slot", slotId);
					player.getTemporaryAttributes().put("bank_isWithdraw", Boolean.TRUE);
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getBank().withdrawItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
					player.getBank().withdrawItemButOne(slotId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getBank().sendExamine(slotId);

			} else if (componentId == 119) {
				openEquipmentBonuses(player, true);
			}
		} else if (interfaceId == 190) {
			if (componentId == 15) {
				if (slotId == 170) {
					player.getInterfaceManager().sendInterface(1245);
					player.getPackets().sendIComponentText(1245, 15, "The Blood Pact");
				} else if (slotId == 1) {
					player.getInterfaceManager().sendInterface(1245);
					player.getPackets().sendIComponentText(1245, 15, "Cook's Assistant");
				}
			}
		} else if (interfaceId == 763) {
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getBank().depositItem(slotId, 1, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getBank().depositItem(slotId, 5, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getBank().depositItem(slotId, 10, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getBank().depositLastAmount(slotId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributes().put("bank_item_X_Slot", slotId);
					player.getTemporaryAttributes().remove("bank_isWithdraw");
					player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getBank().depositItem(slotId, Integer.MAX_VALUE, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if (interfaceId == 767) {
			if (componentId == 10)
				player.getBank().openBank();
		} else if (interfaceId == 884) {
			if (componentId == 4) {
				int weaponId = player.getEquipment().getWeaponId();
				if (player.hasInstantSpecial(weaponId)) {
					player.performInstantSpecial(weaponId);
					return;
				}
				submitSpecialRequest(player);
			} else if (componentId >= 7 && componentId <= 10)
				player.getCombatDefinitions().setAttackStyle(componentId - 7);
			else if (componentId == 11)
				player.getCombatDefinitions().switchAutoRelatie();
		} else if (interfaceId == 755) {
			if (componentId == 44)
				player.getPackets().sendWindowsPane(player.getInterfaceManager().hasRezizableScreen() ? 746 : 548, 2);
			else if (componentId == 42) {
				player.getHintIconsManager().removeAll();// TODO find hintIcon
															// index
				player.getPackets().sendConfig(1159, 1);
			}
		} else if (interfaceId == 20)
			SkillCapeCustomizer.handleSkillCapeCustomizer(player, componentId);
		else if (interfaceId == 1056) {
			if (componentId == 173)
				player.getInterfaceManager().sendInterface(917);
		} else if (interfaceId == 751) {
			if (componentId == 26) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getFriendsIgnores().setPrivateStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getFriendsIgnores().setPrivateStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getFriendsIgnores().setPrivateStatus(2);
			} else if (componentId == 32) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setFilterGame(false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setFilterGame(true);
			} else if (componentId == 29) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setPublicStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.setPublicStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setPublicStatus(2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					player.setPublicStatus(3);
			} else if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getFriendsIgnores().setFriendsChatStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getFriendsIgnores().setFriendsChatStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getFriendsIgnores().setFriendsChatStatus(2);
			} else if (componentId == 23) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setClanStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.setClanStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setClanStatus(2);
			} else if (componentId == 20) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setTradeStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.setTradeStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setTradeStatus(2);
			} else if (componentId == 17) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setAssistStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.setAssistStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setAssistStatus(2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET) {
					// ASSIST XP Earned/Time
				}
			} else if (componentId == 14) {
				player.getInterfaceManager().sendInterface(594);
			}
		} else if (interfaceId == 1163 || interfaceId == 1164 || interfaceId == 1168 || interfaceId == 1170 || interfaceId == 1173)
			player.getDominionTower().handleButtons(interfaceId, componentId);
		else if (interfaceId == 900)
			PlayerLook.handleMageMakeOverButtons(player, componentId);
		else if (interfaceId == 1028)
			PlayerLook.handleCharacterCustomizingButtons(player, componentId);
		else if (interfaceId == 1108 || interfaceId == 1109)
			player.getFriendsIgnores().handleFriendChatButtons(interfaceId, componentId, packetId);
		else if (interfaceId == 1079)
			player.closeInterfaces();
		else if (interfaceId == 374) {
			if (componentId >= 5 && componentId <= 9)
				player.setNextWorldTile(new WorldTile(FightPitsViewingOrb.ORB_TELEPORTS[componentId - 5]));
			else if (componentId == 15)
				player.stopAll();
		} else if (interfaceId == 1092) {
			player.stopAll();
			WorldTile destTile = null;
			switch (componentId) {
			case 47:
				destTile = HomeTeleport.LUMBRIDGE_LODE_STONE;
				break;
			case 42:
				destTile = HomeTeleport.BURTHORPE_LODE_STONE;
				break;
			case 39:
				destTile = HomeTeleport.LUNAR_ISLE_LODE_STONE;
				break;
			case 7:
				destTile = HomeTeleport.BANDIT_CAMP_LODE_STONE;
				break;
			case 50:
				destTile = HomeTeleport.TAVERLY_LODE_STONE;
				break;
			case 40:
				destTile = HomeTeleport.ALKARID_LODE_STONE;
				break;
			case 51:
				destTile = HomeTeleport.VARROCK_LODE_STONE;
				break;
			case 45:
				destTile = HomeTeleport.EDGEVILLE_LODE_STONE;
				break;
			case 46:
				destTile = HomeTeleport.FALADOR_LODE_STONE;
				break;
			case 48:
				destTile = HomeTeleport.PORT_SARIM_LODE_STONE;
				break;
			case 44:
				destTile = HomeTeleport.DRAYNOR_VILLAGE_LODE_STONE;
				break;
			case 41:
				destTile = HomeTeleport.ARDOUGNE_LODE_STONE;
				break;
			case 43:
				destTile = HomeTeleport.CATHERBAY_LODE_STONE;
				break;
			case 52:
				destTile = HomeTeleport.YANILLE_LODE_STONE;
				break;
			case 49:
				destTile = HomeTeleport.SEERS_VILLAGE_LODE_STONE;
				break;
			}
			if (destTile != null)
				player.getActionManager().setAction(new HomeTeleport(destTile));
		} else if (interfaceId == 1214)
			player.getSkills().handleSetupXPCounter(componentId);
		if (interfaceId == 1292) {
			if (componentId == 12)
				Crucible.enterArena(player);
			else if (componentId == 13)
				player.closeInterfaces();
		}
		if (player.getRights() == 2 && Settings.DEBUG) {
			player.sm("InterfaceId " + interfaceId + ", componentId " + componentId + ", slotId " + slotId + ", slotId2 " + slotId2 + ", PacketId: " + packetId);
		}
	}

	public static void sendRemove(Player player, int slotId) {
		if (slotId >= 15)
			return;
		player.stopAll(false, false);
		Item item = player.getEquipment().getItem(slotId);
		if (item == null
				|| !player.getInventory().addItem(item.getId(),
						item.getAmount()))
			return;
		player.getEquipment().getItems().set(slotId, null);
		player.getEquipment().refresh(slotId);
		player.getAppearence().generateAppearenceData();
		if (Runecrafting.isTiara(item.getId()))
			player.getPackets().sendConfig(491, 0);
		if (slotId == 3)
			player.getCombatDefinitions().desecreaseSpecialAttack(0);
	}

	public static boolean sendWear(Player player, int slotId, int itemId) {
		if (player.hasFinished() || player.isDead())
			return false;
		player.stopAll(false, false);
		Item item = player.getInventory().getItem(slotId);
		@SuppressWarnings("unused")
		String itemName = item.getDefinitions() == null ? "" : item.getDefinitions().getName().toLowerCase();
		if (item == null || item.getId() != itemId)
			return false;
		if (item.getDefinitions().isNoted() || !item.getDefinitions().isWearItem(player.getAppearence().isMale())) {
			player.getPackets().sendGameMessage("You can't wear that.");
			return true;
		}
		int targetSlot = Equipment.getItemSlot(itemId);
		if (targetSlot == -1) {
			player.getPackets().sendGameMessage("You can't wear that.");
			return true;
		}
		if (!ItemConstants.canWear(item, player))
			return true;
		boolean isTwoHandedWeapon = targetSlot == 3 && Equipment.isTwoHandedWeapon(item);
		if (isTwoHandedWeapon && !player.getInventory().hasFreeSlots() && player.getEquipment().hasShield()) {
			player.getPackets().sendGameMessage("Not enough free space in your inventory.");
			return true;
		}
		HashMap<Integer, Integer> requiriments = item.getDefinitions().getWearingSkillRequiriments();
		boolean hasRequiriments = true;
		if (requiriments != null) {
			for (int skillId : requiriments.keySet()) {
				if (skillId > 24 || skillId < 0)
					continue;
				int level = requiriments.get(skillId);
				if (level < 0 || level > 120)
					continue;
				if (player.getSkills().getLevelForXp(skillId) < level) {
					if (hasRequiriments) {
						player.getPackets().sendGameMessage("You are not high enough level to use this item.");
					}
					hasRequiriments = false;
					String name = Skills.SKILL_NAME[skillId].toLowerCase();
					player.getPackets().sendGameMessage("You need to have a" + (name.startsWith("a") ? "n" : "") + " " + name + " level of " + level + ".");
				}

			}
		}
		if (!hasRequiriments)
			return true;
		if (!player.getControlerManager().canEquip(targetSlot, itemId))
			return false;
		player.stopAll(false, false);
		player.getInventory().deleteItem(slotId, item);
		if (targetSlot == 3) {
			if (isTwoHandedWeapon && player.getEquipment().getItem(5) != null) {
				if (!player.getInventory().addItem(player.getEquipment().getItem(5).getId(), player.getEquipment().getItem(5).getAmount())) {
					player.getInventory().getItems().set(slotId, item);
					player.getInventory().refresh(slotId);
					return true;
				}
				player.getEquipment().getItems().set(5, null);
			}
		} else if (targetSlot == 5) {
			if (player.getEquipment().getItem(3) != null && Equipment.isTwoHandedWeapon(player.getEquipment().getItem(3))) {
				if (!player.getInventory().addItem(player.getEquipment().getItem(3).getId(), player.getEquipment().getItem(3).getAmount())) {
					player.getInventory().getItems().set(slotId, item);
					player.getInventory().refresh(slotId);
					return true;
				}
				player.getEquipment().getItems().set(3, null);
			}

		}
		if (player.getEquipment().getItem(targetSlot) != null && (itemId != player.getEquipment().getItem(targetSlot).getId() || !item.getDefinitions().isStackable())) {
			if (player.getInventory().getItems().get(slotId) == null) {
				player.getInventory().getItems().set(slotId, new Item(player.getEquipment().getItem(targetSlot).getId(), player.getEquipment().getItem(targetSlot).getAmount()));
				player.getInventory().refresh(slotId);
			} else
				player.getInventory().addItem(new Item(player.getEquipment().getItem(targetSlot).getId(), player.getEquipment().getItem(targetSlot).getAmount()));
			player.getEquipment().getItems().set(targetSlot, null);
		}
		if (targetSlot == Equipment.SLOT_AURA)
			player.getAuraManager().removeAura();
		int oldAmt = 0;
		if (player.getEquipment().getItem(targetSlot) != null) {
			oldAmt = player.getEquipment().getItem(targetSlot).getAmount();
		}
		Item item2 = new Item(itemId, oldAmt + item.getAmount());
		player.getEquipment().getItems().set(targetSlot, item2);
		player.getEquipment().refresh(targetSlot, targetSlot == 3 ? 5 : targetSlot == 3 ? 0 : 3);
		player.getAppearence().generateAppearenceData();
		player.getPackets().sendSound(2240, 0, 1);
		if (targetSlot == 3)
			player.getCombatDefinitions().desecreaseSpecialAttack(0);
		player.getCharges().wear(targetSlot);
		return true;
	}

	public static boolean sendWear2(Player player, int slotId, int itemId) {
		if (player.hasFinished() || player.isDead())
			return false;
		player.stopAll(false, false);
		Item item = player.getInventory().getItem(slotId);
		if (item == null || item.getId() != itemId)
			return false;
		if (item.getDefinitions().isNoted() || !item.getDefinitions().isWearItem(player.getAppearence().isMale()) && itemId != 4084) {
			player.getPackets().sendGameMessage("You can't wear that.");
			return false;
		}
		@SuppressWarnings("unused")
		String itemName = item.getDefinitions() == null ? "" : item.getDefinitions().getName().toLowerCase();
		int targetSlot = Equipment.getItemSlot(itemId);
		if (itemId == 4084)
			targetSlot = 3;
		if (targetSlot == -1) {
			player.getPackets().sendGameMessage("You can't wear that.");
			return false;
		}
		if (!ItemConstants.canWear(item, player))
			return false;
		boolean isTwoHandedWeapon = targetSlot == 3 && Equipment.isTwoHandedWeapon(item);
		if (isTwoHandedWeapon && !player.getInventory().hasFreeSlots() && player.getEquipment().hasShield()) {
			player.getPackets().sendGameMessage("Not enough free space in your inventory.");
			return false;
		}
		HashMap<Integer, Integer> requiriments = item.getDefinitions().getWearingSkillRequiriments();
		boolean hasRequiriments = true;
		if (requiriments != null) {
			for (int skillId : requiriments.keySet()) {
				if (skillId > 24 || skillId < 0)
					continue;
				int level = requiriments.get(skillId);
				if (level < 0 || level > 120)
					continue;
				if (player.getSkills().getLevelForXp(skillId) < level) {
					if (hasRequiriments)
						player.getPackets().sendGameMessage("You are not high enough level to use this item.");
					hasRequiriments = false;
					String name = Skills.SKILL_NAME[skillId].toLowerCase();
					player.getPackets().sendGameMessage("You need to have a" + (name.startsWith("a") ? "n" : "") + " " + name + " level of " + level + ".");
				}

			}
		}
		if (!hasRequiriments)
			return false;
		if (!player.getControlerManager().canEquip(targetSlot, itemId))
			return false;
		player.getInventory().getItems().remove(slotId, item);
		if (targetSlot == 3) {
			if (isTwoHandedWeapon && player.getEquipment().getItem(5) != null) {
				if (!player.getInventory().getItems().add(player.getEquipment().getItem(5))) {
					player.getInventory().getItems().set(slotId, item);
					return false;
				}
				player.getEquipment().getItems().set(5, null);
			}
		} else if (targetSlot == 5) {
			if (player.getEquipment().getItem(3) != null && Equipment.isTwoHandedWeapon(player.getEquipment().getItem(3))) {
				if (!player.getInventory().getItems().add(player.getEquipment().getItem(3))) {
					player.getInventory().getItems().set(slotId, item);
					return false;
				}
				player.getEquipment().getItems().set(3, null);
			}

		}
		if (player.getEquipment().getItem(targetSlot) != null && (itemId != player.getEquipment().getItem(targetSlot).getId() || !item.getDefinitions().isStackable())) {
			if (player.getInventory().getItems().get(slotId) == null) {
				player.getInventory().getItems().set(slotId, new Item(player.getEquipment().getItem(targetSlot).getId(), player.getEquipment().getItem(targetSlot).getAmount()));
			} else
				player.getInventory().getItems().add(new Item(player.getEquipment().getItem(targetSlot).getId(), player.getEquipment().getItem(targetSlot).getAmount()));
			player.getEquipment().getItems().set(targetSlot, null);
		}
		if (targetSlot == Equipment.SLOT_AURA)
			player.getAuraManager().removeAura();
		int oldAmt = 0;
		if (player.getEquipment().getItem(targetSlot) != null) {
			oldAmt = player.getEquipment().getItem(targetSlot).getAmount();
		}
		Item item2 = new Item(itemId, oldAmt + item.getAmount());
		player.getEquipment().getItems().set(targetSlot, item2);
		player.getEquipment().refresh(targetSlot, targetSlot == 3 ? 5 : targetSlot == 3 ? 0 : 3);
		if (targetSlot == 3)
			player.getCombatDefinitions().desecreaseSpecialAttack(0);
		player.getCharges().wear(targetSlot);
		return true;
	}

	public static void submitSpecialRequest(final Player player) {
		CoresManager.fastExecutor.schedule(new TimerTask() {
			@Override
			public void run() {
				try {
					WorldTasksManager.schedule(new WorldTask() {
						@Override
						public void run() {
							player.getCombatDefinitions().switchUsingSpecialAttack();
						}
					}, 0);
				} catch (Throwable e) {
					Logger.handle(e);
				}
			}
		}, 200);
	}

	public static void sendWear(Player player, int[] slotIds) {
		if (player.hasFinished() || player.isDead())
			return;
		boolean worn = false;
		Item[] copy = player.getInventory().getItems().getItemsCopy();
		for (int slotId : slotIds) {
			Item item = player.getInventory().getItem(slotId);
			if (item == null)
				continue;
			if (sendWear2(player, slotId, item.getId()))
				worn = true;
		}
		player.getInventory().refreshItems(copy);
		if (worn) {
			player.getAppearence().generateAppearenceData();
			player.getPackets().sendSound(2240, 0, 1);
		}
	}

	public static void openEquipmentBonuses(final Player player, boolean banking) {
		player.stopAll();
		player.getInterfaceManager().sendInventoryInterface(670);
		player.getPackets().sendUnlockIComponentOptionSlots(670, 0, 0, 27, 0,
				1, 2, 3);
		player.getInterfaceManager().sendInterface(667);
		player.getPackets().sendUnlockIComponentOptionSlots(670, 0, 0, 27, 0,
				1, 2, 3);
		player.getPackets().sendConfigByFile(4894, banking ? 1 : 0);
		player.getPackets().sendItems(93, player.getInventory().getItems());
		player.getPackets().sendInterSetItemsOptionsScript(670, 0, 93, 4, 7,
				"Equip", "Compare", "Stats", "Examine");
		player.getPackets().sendIComponentSettings(667, 14, 0, 13, 1030);
		refreshEquipBonuses(player);
		if (banking) {
			player.getTemporaryAttributes().put("Banking", Boolean.TRUE);
			player.setCloseInterfacesEvent(new Runnable() {
				@Override
				public void run() {
					player.getTemporaryAttributes().remove("Banking");
				}

			});
		}
	}

	public static void refreshEquipBonuses(Player player) {
		player.getPackets().sendIComponentText(667, 28, "Stab: +" + player.getCombatDefinitions().getBonuses()[0]);
		player.getPackets().sendIComponentText(667, 29, "Slash: +" + player.getCombatDefinitions().getBonuses()[1]);
		player.getPackets().sendIComponentText(667, 30, "Crush: +" + player.getCombatDefinitions().getBonuses()[2]);
		player.getPackets().sendIComponentText(667, 31, "Magic: +" + player.getCombatDefinitions().getBonuses()[3]);
		player.getPackets().sendIComponentText(667, 32, "Range: +" + player.getCombatDefinitions().getBonuses()[4]);
		player.getPackets().sendIComponentText(667, 33, "Stab: +" + player.getCombatDefinitions().getBonuses()[5]);
		player.getPackets().sendIComponentText(667, 34, "Slash: +" + player.getCombatDefinitions().getBonuses()[6]);
		player.getPackets().sendIComponentText(667, 35, "Crush: +" + player.getCombatDefinitions().getBonuses()[7]);
		player.getPackets().sendIComponentText(667, 36, "Magic: +" + player.getCombatDefinitions().getBonuses()[8]);
		player.getPackets().sendIComponentText(667, 37, "Range: +" + player.getCombatDefinitions().getBonuses()[9]);
		player.getPackets().sendIComponentText(667, 38, "Summoning: +" + player.getCombatDefinitions().getBonuses()[10]);
		player.getPackets().sendIComponentText(667, 39, "Absorb Melee: +" + player.getCombatDefinitions().getBonuses()[CombatDefinitions.ABSORVE_MELEE_BONUS] + "%");
		player.getPackets().sendIComponentText(667, 40, "Absorb Magic: +" + player.getCombatDefinitions().getBonuses()[CombatDefinitions.ABSORVE_MAGE_BONUS] + "%");
		player.getPackets().sendIComponentText(667, 41, "Absorb Ranged: +" + player.getCombatDefinitions().getBonuses()[CombatDefinitions.ABSORVE_RANGE_BONUS] + "%");
		player.getPackets().sendIComponentText(667, 42, "Strength: " + player.getCombatDefinitions().getBonuses()[14]);
		player.getPackets().sendIComponentText(667, 43, "Ranged Str: " + player.getCombatDefinitions().getBonuses()[15]);
		player.getPackets().sendIComponentText(667, 44, "Prayer: +" + player.getCombatDefinitions().getBonuses()[16]);
		player.getPackets().sendIComponentText(667, 45, "Magic Damage: +" + player.getCombatDefinitions().getBonuses()[17] + "%");
	}

	public static void sendMissionBoard(Player player) {
		// TODO Auto-generated method stub

	}
}